package util

const CODE_SUCCESS = 200
const CODE_ERROR = 500

const SUCCESS = true
const ERROR = false

type DagResult struct {
	Code    int         `json:"code"`
	Data    interface{} `json:"data"`
	Message string      `json:"message"`
	Success bool        `json:"success"`
}

func GenSuccess() *DagResult {
	return &DagResult{
		Code:    CODE_SUCCESS,
		Data:    nil,
		Message: "操作成功",
		Success: SUCCESS,
	}
}

func GenSuccessMsg(msg string) *DagResult {
	return &DagResult{
		Code:    CODE_SUCCESS,
		Data:    nil,
		Message: msg,
		Success: SUCCESS,
	}
}

func GenErrorMsg(msg string) *DagResult {
	return &DagResult{
		Code:    CODE_ERROR,
		Data:    nil,
		Message: msg,
		Success: ERROR,
	}
}
